package com.example.demo.service;


import java.io.FileOutputStream;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.HashMap;
import java.util.Map;

public class FileChannelOut {
	static Map<String,String[]> map = new HashMap<>();
	public static void main(String[] args) throws Exception{
		try(FileOutputStream out = new FileOutputStream("E:\\temp\\hello.txt");FileChannel channel = out.getChannel();) {
			ByteBuffer buffer = ByteBuffer.wrap("hello world".getBytes());
			channel.write(buffer);
			System.out.println(buffer.position());
			System.out.println(buffer.limit());
			buffer.flip();
			System.out.println(buffer.position());
			System.out.println(buffer.limit());
			byte[] dist = new byte[11];
			buffer.get(dist);
			System.out.println(new String(dist));
			System.out.println(buffer.position());
			System.out.println(buffer.limit());
		}
	}
}